Fix this.getInitialState is not a function err in DropZone component #7365
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #7353. During refactoring the DropZone component,
getInitialState
method was removed. However, its call inresetDragState
method was not removed which causes 2169 errors in 24 hour period (thanks @artpi for your work on JS error logging!).In this PR, I propose a simple fix in which we reset state in
resetDragState
more verbosely by enumerating specific props and their initial values instead of calling some method. Props @aduth for this solution and help.I also reuse the
resetDragState
method inonDrop
event handler as the resetting functionality was unnecessarily duplicated there.Testing Instructions
To be honest, I couldn't reproduce the issue the "normal" way. I couldn't get the mouseup event triggered by using Calypso (maybe you could, here are some steps).
Fortunately, we can create and fire events manually through Dev Console. So, firstly, let's reproduce the bug and then see if it's fixed:
master
branch and openclient/components/drop-zone/index.jsx
in your favorite editor;this.getInitialState is not a function
error;cc @aduth @ockham @gwwar @timmyc @artpi
Test live: https://calypso.live/?branch=fix/drop-zone-reset-drag-state